$(function(){
    setEndTrTd();
    $('body').on('click','#downloadExcel',function(){

        var that =$(this).find('span');
        var id =that.data("id");
        var type =$(this).data('type');
        var commentIds = getIsCheckbox();
        var params = 'id=' + id +'&commentIds=' + commentIds+"&type="+type;
        if(type=="evaluation"){
            location.href=baseloaction + '/admin/course/profile/downloadExcelDetailList?' + params, '_blank';
        }else{
            exportExecl.init({
                    title:"导出章节评价明细",
                    excelUrl: '/admin/course/profile/downloadExcelDetailList?' + params,
                    type:7
                }
            )
        }


    });

    function getIsCheckbox(){
        var checked = $('input[type=checkbox]:checked');
        var ids = checked.map(function () {
            return this.value;
        }).get().join(',');
        return ids;
    };

    function setEndTrTd() {
        //设置最后一行的显示标签
        var list = $(".table-bordered");
        if (list != null && list.length > 0) {
            $.each(list, function (index, em) {
                var trList = $(em).find("tr");
                if (trList != null && trList.length > 0) {
                    var endTr = trList[trList.length - 1];
                    $(endTr).find('[data-toggle="tooltip"]').data("placement", "top");
                    var tdList = $(endTr).find('td');
                    if (tdList != null && tdList.length > 0) {
                        var endTd = tdList[tdList.length - 1];
                        var a =$(endTd).find("a");
                        $(endTd).find("a").data("placement", "left");
                    }
                }
            });
        }
    };
});